<?php

/**
 * 轮播图
 */

namespace app\api\controller;

use app\common\controller\ApiController;
use custom\Dense;
use think\Exception;
use app\api\model\Banner as BannerModel;

class DencTest extends ApiController {
    protected $isSign = false;
    protected $isEncrypt = false;

//    protected $notNeedToken = ['gethousebanner'];

    protected $notNeedPhone = ['gethousebanner'];

    protected $isArrayResult = ['gethousebanner'];

    const STR_LEN = 16;
    protected $cipher = 'AES-128-CBC';
    public function setCipher($cipher = 'AES-128-CBC') {
        $this->cipher = $cipher;
    }
    /**
     * ios默认加密key
     * @var string
     */
    protected $ios_key='ios(%#*&h2k3s4d-';
    /**
     * 安卓默认加密key
     * @var string
     */
    protected $and_key='and(&$@*f5s7k9u+';
    /**
     * @return false|string
     */
    public function denc() {
        $params = $this->checkParams('');
        $datas=$params['datas'];
            $info=$this->uInfo;
            $headers=$this->headers;
            if (isset($info['en_key'])&&$info['en_key']){
                $key=$info['en_key'];
            }else{
                if ($headers['os']==1){
                    $key=$this->ios_key;
                }else{
                    $key=$this->and_key;
                }
            }
            $buff=hex2bin($datas);
            $encData = substr($buff, 16);
        var_dump($encData);
            $encData=hex2bin($encData);
            $iv = substr($buff, 0, 16);

            $re = openssl_decrypt($encData, $this->cipher, $key, OPENSSL_RAW_DATA, $iv);
            print_r($re);

    }

}
